<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<title>弹窗</title>
	<meta name ="description" content="弹窗">
    <style>
        /* 完善资料弹窗 */
        .pop_layer{display:block;padding:20px;overflow:hidden;}
        .pop_layer .label_box{width:100%;margin-top:20px;overflow:hidden;}
        .pop_layer .label_box dl{width:100%;overflow:hidden;padding:5px 0;}
        .pop_layer .label_box dl dt{width:22%;float:left;text-align:right;font-size:14px;line-height:36px;color:#555c73;}
        .pop_layer .label_box dl dd{width:75%;float:right;overflow:hidden;}
        .pop_layer .label_box dl dd label{display:block;float:left;width:35%;font-size:14px;line-height:36px;}
        .pop_layer .label_box dl dd label input{display:inline-block;vertical-align:top;width:16px;height:16px;padding:0;margin:10px 6px 0 0;}
        .pop_layer .label_box dl dd span.input{display:block;border:#d9d9d9 1px solid;overflow:hidden;width:80%;}
        .pop_layer .label_box dl dd span.input input{display:block;border:0;padding:0;margin:0;text-indent:10px;font-size:14px;height:34px;width:100%;outline: none;}
        .pop_layer .label_box dl dd span.select{display:block;border:#d9d9d9 1px solid;overflow:hidden;width:25.75%;float:left;margin-right:1%;}
        .pop_layer .label_box dl dd span.select select{display:block;border:0;padding:0;margin:0;text-indent:5px;font-size:14px;height:34px;width:100%;outline: none;}
        .pop_layer .label_box dl dd span.phone{display:block;font-size:14px;line-height:36px;color:#555c73;}
        .pop_layer .label_box dl dd a.sub_nav{display:block;width:50%;background-color:#166df1;color:#fff;text-align:center;line-height:40px;}
        .select2-container{
            z-index: 999999999;
        }
        .select2-container .select2-selection--single{
            border:0;border-radius:inherit;
        }
        input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
            　　color: #fff;
            　　}
        　　input:-moz-placeholder, textarea:-moz-placeholder {
            　　color:#fff;
            　　}
        　　input::-moz-placeholder, textarea::-moz-placeholder {
            　　color:#fff;
            　　}
        　　input:-ms-input-placeholder, textarea:-ms-input-placeholder {
            　　color:#fff;
            　　}
    </style>

</head>
<body>
<div class="pop_layer">
    <div class="label_box">
        <dl>
            <dt>姓名：</dt>
            <dd>
                <span class="input"><input id="dress_uname" placeholder="姓名" onfocus="this.placeholder=''" onblur="this.placeholder='姓名'"></span>
            </dd>
        </dl>
        <dl>
            <dt>电话</dt>
            <dd>
                <span class="input"><input id="dress_utel" placeholder="电话" onfocus="this.placeholder=''" onblur="this.placeholder='电话'"></span>
            </dd>
        </dl>
        <dl>
            <dt>地址：</dt>
            <dd>
            	<span class="select">
                   <select name="province_id" id="province_id" class="form-control select2" size="1">
                        <?php if(isset($province) && !empty($province)){ ?>
                            <?php foreach ($province as $key =>$val ) { ?>
                                <option value="<?php echo $val['area_id'];?>" ><?php echo $val['area_name'];?></option>
                            <?php }?>
                        <?php }?>
                    </select>
                </span>
                <span class="select">
                   <select name="city_id" id="city_id" class="form-control select2" size="1">
                            <option value="0">请选择市</option>
                   </select>
                </span>
                <span class="select">
                        <select name="district_id" id="district_id" class="form-control select2" size="1">
                                    <option value="0">请选择区</option>
                        </select>
                </span>
            </dd>
        </dl>
        <dl>
            <dt> </dt>
            <dd>
                <span class="input"><input placeholder="详细地址" id="address"></span>
            </dd>
        </dl>
        <dl>
            <dt>设为默认地址：</dt>
            <dd>
                <label><input name="dress_type" type="radio" value="1" checked>是</label>
                <label><input name="dress_type" type="radio" value="2" >否</label>
            </dd>
        </dl>
        <dl>
            <dt>&nbsp;</dt>
            <dd>
                <button class="layui-btn layui-btn-normal"  id="doModify">提交</button>
            </dd>
        </dl>
    </div>
</div>
<?php echo admin_js_url('area2');?>
<script>
    var ajaxurl = "<?php echo site_url('area/get_area');?>";
	// 提交
	$("#doModify").click(function(){
        var dress_type = $('input[name="dress_type"]:checked').val();
		var dress_uname      = $("#dress_uname").val();
        var dress_utel      = $("#dress_utel").val();
		var address = $("#address").val();
        var province_id = $("#province_id").val();
        var city_id = $("#city_id").val();
        var district_id = $("#district_id").val();
		// alert(nums);return false;
        if (province_id=="") {
            layer.msg('请选择所在省');
            return false;
        }
        if (city_id=="") {
            layer.msg('请选择所在市');
            return false;
        }
        if (address=="") {
            layer.msg('请填写详细地址');
            return false;
        }
        if (dress_utel=="") {
            layer.msg('请填写填写电话');
            return false;
        }
		var URL= baseurl+"index.php/manage/orders/add_addr";
		$.ajax({
			type: "post",
			url: URL,
			dataType:'json',
			data: {
                'dress_type':dress_type,
				'dress_uname':dress_uname,
                'dress_utel':dress_utel,
                'address':address,
                'province':province_id,
                'city':city_id,
                'district':district_id,
			},
			success: function(data){
				if(data.code == 200){
					layer.msg(data.msg, {
						time: 2000, //20s后自动关闭
					});
					window.location.href = window.location.href;
				}else{
					layer.msg(data.msg, {
						time: 3000, //20s后自动关闭
					});
				}


			}
		});
	});
</script>
</body>
</html>